package cn.tedu.store.controller;

import cn.tedu.store.entity.District;
import cn.tedu.store.service.IDistrictService;
import cn.tedu.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/districts")
public class DistrictController {
    @Autowired
    IDistrictService service;

    @RequestMapping("/")
    public JsonResult<List<District>> findDistrict(HttpServletResponse resp, String parent){
        resp.setHeader("Access-Control-Allow-Origin", "*");

        List<District> list=service.findByParent(parent);

        return JsonResult.getSuccessJR(list);
    }
}
